/**
 * 
 */
package cs3201.westga.edu.project_2;

import java.util.Scanner;

/**
 * MathDriver is the main driver for project 2. It handles all user interfacing.
 * 
 * @author Cody Stamps
 * 
 */
public class MathDriver {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		//REQUIRES a valid number selection be used.
		
			int answer = 0;
			while (answer != 5){
				Scanner scan = new Scanner(System.in);
				System.out.println("What would you like to do?");
				System.out.println("1.Find the area of a triangle");
				System.out.println("2.Find the area of a circle");
				System.out.println("3.Find the volume of a cube");
				System.out.println("4.Find the volume of a sphere");
				System.out.println("5.Exit");
				try{
					answer = scan.nextInt();
				if (answer != 1 && answer != 2 && answer !=3 && answer != 4 && answer != 5){
					throw new IllegalArgumentException("You have input an invalid selection");
				}
				if (answer == 1){
					System.out.println("You have choosen to find the area of a triangle. What should the base be?");
					double base = scan.nextDouble();
					System.out.println("What should the height be?");
					double height = scan.nextDouble();
					Triangle t = new Triangle(base,height);
					System.out.println("The area is " + t.getArea());
				}
				if (answer == 2){
					System.out.println("You have choosen to find the area of a circle. What should the radius be?");
					double radius = scan.nextDouble();
					Circle c = new Circle(radius);
					System.out.println("The area is " + c.getArea());
				}
				if (answer == 3){
					System.out.println("You have choosen to find the volume of a cube. What should the length be?");
					double length = scan.nextDouble();
					Cube cube = new Cube(length);
					System.out.println("The volume is " + cube.getVolume());
				}
				if (answer == 4){
					System.out.println("You have choosen to find the volume of a sphere. What should the radius be?");
					double radius2 = scan.nextDouble();
					Sphere sphere = new Sphere(radius2);
					System.out.println("The volume is " + sphere.getVolume());
				}
			}
			catch(IllegalArgumentException iae){
				System.out.println(iae.getMessage());
			}
			catch(Exception e){
				System.out.println("You have input an invalid selection.");
			}
		}
		System.out.println("Goodbye");
	}
}
